import type { RouteLocationNormalized } from 'vue-router'

const title = '杭州国家版本馆'

export const setTitle = (to: RouteLocationNormalized) => {
  if (!to.meta.title) return (document.title = title)
  document.title = `${to.meta.title} - ${title}`
}

export class RecordType {
  static OverTimeRouteName = false // 加班详情
  static HaveDinnerRouteName = false // 用餐详情
  static LeaveRouteName = false // 请假详情
  static AttendanceRouteName = false // 补签详情
  static OnBusinessRouteName = false // 出差详情
  static WorkoutsideRouteName = false // 公出详情
  static UsecarRouteName = false // 用车详情
  static DispatchRouteName = false // 发文详情
  static SealRouteName = false // 用章详情
  static ProcessingRouteName = false //阅办详情
  static ShredLeaveRouteName = false //销假详情
  static InOutRouteName = false //出入证详情
  static DispatchRecyleRouteName = false //发文回收详情
  static PetitionRouteName = false //信访详情
  static ProcureRouteName = false //采购需求详情
  static ProcureRouteName2 = false //采购详情
  static BuildRouteName = false //党建发文详情
  static ContractTransformRouteName = false //合同流转详情
  static FileRouteName = false //档案借阅详情
  static makeMenuFirst = false //编目初审详情
  static makeAccount = false //报销申请
  static signDuty = false //值班申请
  static governmentInfo = false //政采申请
  static LaborInfo = false //劳务费申请
  static AssessInfo = false //考核申请
  static AssetsReceiveRouteName = false //资产领用
  static AssetsReturnRouteName = false //资产归还
  static AssetsTransferRouteName = false //资产转移
  static DigitalCollectRouteName = false // 数字藏品申请

  // 资产领用
  static isAssetsReceive(code: string) {
    return code === 'A0569'
  }
  // 资产归还
  static isAssetsReturn(code: string) {
    return code === 'A0570'
  }
  // 资产转移
  static isAssetsTransfer(code: string) {
    return code === 'A0571'
  }
  // 数字藏品
  static isDigitalCollect(code: string) {
    return code === 'A0576'
  }
  // 考核
  static isAssess(code: string) {
    return code === 'A0558'
  }
  // 劳务费
  static isLabor(code: string) {
    return code === 'A0553' || code === 'A0554' || code === 'A0555'
  }
  // 政采
  static isGovernment(code: string) {
    return code === 'A0525' || code === 'A0526' || code === 'A0527'
  }
  // 报销
  static isSignDuty(code: string) {
    return code === 'A0515'
  }
  // 报销
  static isAccount(code: string) {
    return code === 'A0548' || code === 'A0549' || code === 'A0550'
  }
  // 编目初审
  static isMakeMenuFirst(code: string) {
    return code === 'A0546'
  }
  // 加班
  static isOverTime(code: string) {
    return code === 'A0502'
  }
  // 用餐
  static isHaveDinner(code: string) {
    return code === 'A0533' || code === 'A0551' || code === 'A0552'
  }
  // 请假
  static isLeave(code: string) {
    return code === 'A0520' || code === 'A0521' || code === 'A0522'
  }
  // 补签
  static isAttendance(code: string) {
    return code === 'A0513'
  }
  // 出差
  static isOnBusiness(code: string) {
    return code === 'A0504' || code === 'A0505'
  }
  // 公出
  static isWorkoutside(code: string) {
    return code === 'A0528'
  }
  // 用车
  static isUsecar(code: string) {
    return code === 'A0518' || code === 'A0519'
  }
  // 发文
  static isDispatch(code: string) {
    return code === 'A0501'
  }
  // 用章
  static isSeal(code: string) {
    return ['A0507', 'A0564', 'A0565', 'A0566', 'A0562', 'A0563', 'A0560', 'A0561'].includes(code)
  }
  //销假
  static isShredLeave(code: string) {
    return code === 'A0523'
  }
  //发文回收
  static isDispatchRecyle(code: string) {
    return code === 'A0544'
  }
  //出入证
  static isInOut(code: string) {
    return code === 'A0531'
  }
  //信访
  static isPetition(code: string) {
    return code === 'A0516'
  }
  //采购需求
  static isProcure(code: string) {
    return code === 'A0524' || code === 'A0567' || code === 'A0568'
  }
  //采购
  static isProcure2(code: string) {
    return code === 'A0577'
  }
  //党建发文
  static isBuild(code: string) {
    return code === 'A0506'
  }
  //合同流转
  static isContractTransform(code: string) {
    return code === 'A0509' || code === 'A0510' || code === 'A0511'
  }
  //档案借阅
  static isFile(code: string) {
    return code === 'A0532'
  }

  static async setRouteNameTypeTrue(code: string) {
    if (RecordType.isOverTime(code)) return (RecordType.OverTimeRouteName = true) // 加班
    if (RecordType.isHaveDinner(code)) return (RecordType.HaveDinnerRouteName = true) // 用餐
    if (RecordType.isLeave(code)) return (RecordType.LeaveRouteName = true) // 请假
    if (RecordType.isAttendance(code)) return (RecordType.AttendanceRouteName = true) // 补签
    if (RecordType.isOnBusiness(code)) return (RecordType.OnBusinessRouteName = true) // 出差
    if (RecordType.isWorkoutside(code)) return (RecordType.WorkoutsideRouteName = true) // 公出
    if (RecordType.isUsecar(code)) return (RecordType.UsecarRouteName = true) // 用车
    if (RecordType.isDispatch(code)) return (RecordType.DispatchRouteName = true) // 发文
    if (RecordType.isSeal(code)) return (RecordType.SealRouteName = true) // 用章
    if (RecordType.isShredLeave(code)) return (RecordType.ShredLeaveRouteName = true) //销假
    if (RecordType.isDispatchRecyle(code)) return (RecordType.DispatchRecyleRouteName = true) //发文回收
    if (RecordType.isInOut(code)) return (RecordType.InOutRouteName = true) //出入证
    if (RecordType.isPetition(code)) return (RecordType.PetitionRouteName = true) //信访
    if (RecordType.isProcure(code)) return (RecordType.ProcureRouteName = true) //采购需求
    if (RecordType.isProcure2(code)) return (RecordType.ProcureRouteName2 = true) //采购
    if (RecordType.isBuild(code)) return (RecordType.BuildRouteName = true) //党建发文
    if (RecordType.isContractTransform(code)) return (RecordType.ContractTransformRouteName = true) //合同流转
    if (RecordType.isFile(code)) return (RecordType.FileRouteName = true) //档案借阅
    if (RecordType.isMakeMenuFirst(code)) return (RecordType.makeMenuFirst = true) //编目初审
    if (RecordType.isAccount(code)) return (RecordType.makeAccount = true) //报销申请
    if (RecordType.isSignDuty(code)) return (RecordType.signDuty = true) //值班申请
    if (RecordType.isGovernment(code)) return (RecordType.governmentInfo = true) //政采申请
    if (RecordType.isLabor(code)) return (RecordType.LaborInfo = true) //劳务费申请
    if (RecordType.isAssess(code)) return (RecordType.AssessInfo = true) //考核申请
    if (RecordType.isAssetsReceive(code)) return (RecordType.AssetsReceiveRouteName = true) //资产领用
    if (RecordType.isAssetsReturn(code)) return (RecordType.AssetsReturnRouteName = true) //资产归还
    if (RecordType.isAssetsTransfer(code)) return (RecordType.AssetsTransferRouteName = true) //资产转移
    if (RecordType.isDigitalCollect(code)) return (RecordType.DigitalCollectRouteName = true) // 数字藏品申请
  }

  static async setRouteNameTypeFalse(code: string) {
    if (RecordType.isOverTime(code)) return (RecordType.OverTimeRouteName = false) // 加班
    if (RecordType.isHaveDinner(code)) return (RecordType.HaveDinnerRouteName = false) // 用餐
    if (RecordType.isLeave(code)) return (RecordType.LeaveRouteName = false) // 请假
    if (RecordType.isAttendance(code)) return (RecordType.AttendanceRouteName = false) // 补签
    if (RecordType.isOnBusiness(code)) return (RecordType.OnBusinessRouteName = false) // 出差
    if (RecordType.isWorkoutside(code)) return (RecordType.WorkoutsideRouteName = false) // 公出
    if (RecordType.isUsecar(code)) return (RecordType.UsecarRouteName = false) // 用车
    if (RecordType.isDispatch(code)) return (RecordType.DispatchRouteName = false) // 发文
    if (RecordType.isSeal(code)) return (RecordType.SealRouteName = false) // 用章
    if (RecordType.isShredLeave(code)) return (RecordType.ShredLeaveRouteName = false) //销假
    if (RecordType.isDispatchRecyle(code)) return (RecordType.DispatchRecyleRouteName = false) //发文回收
    if (RecordType.isInOut(code)) return (RecordType.InOutRouteName = false) //出入证
    if (RecordType.isPetition(code)) return (RecordType.PetitionRouteName = false) //信访
    if (RecordType.isProcure(code)) return (RecordType.ProcureRouteName = false) //采购需求
    if (RecordType.isProcure2(code)) return (RecordType.ProcureRouteName2 = false) //采购
    if (RecordType.isBuild(code)) return (RecordType.BuildRouteName = false) //党建发文
    if (RecordType.isContractTransform(code)) return (RecordType.ContractTransformRouteName = false) //合同流转
    if (RecordType.isFile(code)) return (RecordType.FileRouteName = false) //档案借阅
    if (RecordType.isMakeMenuFirst(code)) return (RecordType.makeMenuFirst = false) //编目初审
    if (RecordType.isAccount(code)) return (RecordType.makeAccount = false) //报销申请
    if (RecordType.isSignDuty(code)) return (RecordType.signDuty = false) //值班申请
    if (RecordType.isGovernment(code)) return (RecordType.governmentInfo = false) //政采申请
    if (RecordType.isLabor(code)) return (RecordType.LaborInfo = false) //劳务费申请
    if (RecordType.isAssess(code)) return (RecordType.AssessInfo = false) //考核申请
    if (RecordType.isAssetsReceive(code)) return (RecordType.AssetsReceiveRouteName = false) //资产领用
    if (RecordType.isAssetsReturn(code)) return (RecordType.AssetsReturnRouteName = false) //资产归还
    if (RecordType.isAssetsTransfer(code)) return (RecordType.AssetsTransferRouteName = false) //资产转移
  }
}
